package com.dhcc.bpm.modules.gateway.service.impl;

import com.dhcc.bpm.modules.gateway.entity.GatewayRoute;
import com.dhcc.bpm.modules.gateway.vo.GatewayRouteVO;
import com.dhcc.bpm.modules.gateway.mapper.GatewayRouteMapper;
import com.dhcc.bpm.modules.gateway.service.IGatewayRouteService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

/**
 * @ClassName GatewayRouteServiceImpl
 * @Description 网关路由表 服务实现类
 * @Author YaoZC
 * @Date 2019/11/26 16:08
 * @Version 1.0
 * @Copyright: 2019 东华软件 . All rights reserved.
 */
@Service("opc_gateway_route")
public class GatewayRouteServiceImpl extends BaseServiceImpl<GatewayRouteMapper, GatewayRoute> implements IGatewayRouteService {

    @Autowired
    private GatewayRouteMapper gatewayRouteMapper;

    /**
     * @param page
     * @param gatewayRoute
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.gateway.vo.GatewayRouteVO>
     * @Description 自定义分页
     * @Date 2019/11/26 16:08
     **/
    @Override
    public IPage<GatewayRouteVO> selectGatewayRoutePage(IPage<GatewayRouteVO> page, GatewayRouteVO gatewayRoute) {
        return page.setRecords(baseMapper.selectGatewayRoutePage(page, gatewayRoute));
    }

    /**
     * @param page
     * @param gatewayRoute
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.gateway.vo.GatewayRouteVO>
     * @Description 根据基础产品查路由列表和根据api查路由列表
     * @Date 2019/11/26 16:08
     **/
    @Override
    public IPage<GatewayRouteVO> listGatewayRoute(IPage<GatewayRouteVO> page, GatewayRouteVO gatewayRoute) {
        return page.setRecords(baseMapper.listGatewayRoute(page, gatewayRoute));
    }

    /**
     * @param id
     * @return java.util.List<com.dhcc.bpm.modules.gateway.vo.GatewayRouteVO>
     * @Description 根据网关id获取网关路由信息
     * @Date 2019/11/26 16:08
     **/
    @Override
    public List<GatewayRouteVO> getByGatewayId(Long id) {
        return gatewayRouteMapper.selectByGatewayId(id);
    }

    @Override
    public List<GatewayRouteVO> getByApiId(String apiId) {
        return gatewayRouteMapper.getByApiId(apiId);
    }

    @Override
    public List<GatewayRouteVO> getByBaceServiceId(Long backServiceId) {
        return gatewayRouteMapper.getByBaceServiceId(backServiceId);
    }

    /**
     * @param apiId
     * @return java.util.List<com.dhcc.bpm.modules.gateway.vo.GatewayRouteVO>
     * @Description 根据网关id获取网关路由信息
     * @Date 2019/11/26 16:08
     **/
    @Override
    public GatewayRouteVO getGatewayByApiId(String apiId, String env) {
        return gatewayRouteMapper.getGatewayByApiId(apiId, env);
    }

    @Override
    public int updateBackServiceIdByApiId(GatewayRouteVO gatewayRoute) {
        return gatewayRouteMapper.updateBackServiceIdByApiId(gatewayRoute);
    }

    @Override
    public List<GatewayRouteVO> findByServerId(Long externalcallId) {
        return gatewayRouteMapper.findByServerId(externalcallId);
    }

    @Override
    public List<GatewayRouteVO> queryOrder(GatewayRoute gatewayRoute) {
        return gatewayRouteMapper.queryOrder(gatewayRoute);
    }

    @Override
    public Integer queryMaxOrder(GatewayRoute gatewayRoute) {
        return gatewayRouteMapper.queryMaxOrder(gatewayRoute);
    }

    @Override
    public List<GatewayRoute> findOrderChild(GatewayRoute gatewayRoute) {
        return gatewayRouteMapper.findOrderChild(gatewayRoute);
    }
}
